package day22.SecondTest;

import java.util.*;

public class Student {
    private Integer no;
    private String name;
    private Integer score;

    public Student(Integer no, String name, Integer score) {
        this.no = no;
        this.name = name;
        this.score = score;
    }

    public Integer getNo() {
        return no;
    }

    public void setNo(Integer no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(no, student.no) && Objects.equals(name, student.name) && Objects.equals(score, student.score);
    }

    @Override
    public int hashCode() {
        return Objects.hash(no, name, score);
    }

    @Override
    public String toString() {
        return "no:" + no + " name:" + name + " score:" + score ;
    }

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        Map<Integer,Student> map=new TreeMap<>();

        int n= sc.nextInt();
        for (int i = 0; i< n; i++) {
            int a= sc.nextInt();
            Student stu= new Student(a,sc.next(),sc.nextInt());
            map.put(a,stu);
        }
        int m= sc.nextInt();
        for (int i = 0; i < m; i++) {
            String operation = sc.next();
            if( operation.equals("add")){
                int a= sc.nextInt();
                Student stu= new Student(a,sc.next(),sc.nextInt());
                map.put(a,stu);
            }
            else if( operation.equals("delete")){
                map.remove(sc.nextInt());
            }
            else if( operation.equals("set")){
                map.get(sc.nextInt()).setScore(sc.nextInt());
            }
        }
        for (Student student : map.values()) {
            System.out.println(student.toString());
        }
    }

}
